<!DOCTYPE html>
<html class="no-js" lang="">

<head>#include( "/public-head.html")
</head>

<body style="background-color: #ffffff !important;">
	<div class="main-content checkbo">
		<div class="panel mb25">
			<div class="panel-heading border">分配-权限</div>
			<div class="panel-body">
				<div class="row no-margin">
				<form action="/vrs/permission/distributePermissionForUser.jsn" data-url="/vrs/user/list.jsn" id="configForm" name="ajaxForm" class="form-horizontal bordered-group" role="form">
					
					<input type="hidden" name="userId" value="$!{userId}">
					<input type="hidden" name="permissionIds" id="permissionIds" value="">
					<div class="col-lg-12">
						<div id="treeDemo" class="ztree" style="height: 300px;"></div>
						<div class="form-group">
							<label></label>
							<div>
								<button type="button" onclick="submitCPerForm()" class="btn btn-primary mr10">#if($!role.roleId) 修改#else 保存#end</button>
								<button class="btn btn-default">返回</button>
							</div>
						</div>
					</div>
				</form>
				</div>
			</div>
		</div>


	</div>
	<!-- /main area -->

	#include( "/public-script.html") 
	#include( "/sub-script.html")
	<script>
	//父节点选择
	var treeMenu = [{"id":0,"open":true,"name":"VRS系统","children":$!{menu}}];
	funCreateCheckboxTree("treeDemo",treeMenu);
	
	//提交
	function submitCPerForm() {
		//获取选择ID
		var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
		var nodes = treeObj.getCheckedNodes(true);
		var permissionIds = "";
		for (var i = 0; i < nodes.length; i++) {
			if(i+1 == nodes.length){
				permissionIds +=nodes[i].id;
			}else{
				permissionIds += nodes[i].id+",";
			}
		}
		$("#permissionIds").val(permissionIds);
		//请求
		$('#configForm').submit();
	}
	</script>
</body>

</html>
